package cn.echoedu.model;

import java.sql.SQLException;
import java.util.List;

import cn.echoedu.daoconstants.TableName;
import cn.echoedu.entity.TelContacts;
import cn.echoedu.util.L;
/**
 * tel contacts control
 * @author Administrator
 *
 */
public class TelContactsModel extends BaseModel{
	private final String T="TelContractsControl----------->";
	 
	 public TelContactsModel(){
		 
		L.p(T+"TelContactsControl");
		 

	}
//	public List<TelContacts> queryByType(String command) throws SQLException {
//		// TODO Auto-generated method stub
//		dbinstance=DBInstance.getInstanceDBInstance();
//		List<TelContacts> list=basedao.getAllForInput(dbinstance.getConnection(),
//				cn.echoedu.dao.mydb.TableName.TEL_CONTACTS_TABLE, 
//				"type",command);
//		return list;
//	}
  
public List<TelContacts> queryByLeftJoinAndCommand(String command,String sortbysql,int schoolcode,int departmentcode,int classcode,int code) throws SQLException {
	// TODO Auto-generated method stub
	   List<TelContacts> list;
	   String sql = null;
	   if(code == 301){
		   System.out.println("办公电话");
			sql="select * from "+TableName.TEL_CONTACTS_TABLE+" left join "+TableName.IMAGE_TABLE+
				" on ("+TableName.TEL_CONTACTS_TABLE+".imageid ="+TableName.IMAGE_TABLE+".imageid)" +
				" where type = 1 "+sortbysql;
		}
		else if(code == 302){
			System.out.println("校友录");
			sql="select * from "+TableName.TEL_CONTACTS_TABLE+" left join "+TableName.IMAGE_TABLE+
					" on ("+TableName.TEL_CONTACTS_TABLE+".imageid ="+TableName.IMAGE_TABLE+".imageid)" +
					" where type = 0 "+sortbysql;
		}
		else if(code == 304){
			System.out.println("班友录");
			sql="select * from "+TableName.TEL_CONTACTS_TABLE+" left join "+TableName.IMAGE_TABLE+
					" on ("+TableName.TEL_CONTACTS_TABLE+".imageid ="+TableName.IMAGE_TABLE+".imageid)" +
					" where type = 0 "+sortbysql+"and schoolcode ="+schoolcode+" and classcode ="+classcode;
		}
		else if(code == 305){
			System.out.println("热门电话");
			sql="select * from "+TableName.TEL_CONTACTS_TABLE+" left join "+TableName.IMAGE_TABLE+
					" on ("+TableName.TEL_CONTACTS_TABLE+".imageid ="+TableName.IMAGE_TABLE+".imageid)" +
					" where ishot = 1 "+sortbysql;
		}
	   list = getDAORead().getPojoForSql(getConnection(), TableName.TEL_CONTACTS_TABLE, sql);
	   return list;
}
 

}
